<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <input type="text" id="username">
    <input type="text" id="password">

    <script>
        var username = document.getElementById("username");
        username.oninput = function(e){
            console.log(e.target.value);
        }//输入框内容每次发生变化时发生事件，用于检测输入框内的实时内容

        username.onselect = function(){
            console.log("选中了");
        }//选中输入框内容时触发

        var password = document.getElementById("password");
        password.onchange = function(e){
            console.log(e.target.value);
        }//输入框值完成修改时触发，如当失去焦点或摁下回车时，频率比input更低

    </script>
</body>
</html>